path = 'F:\workspace\EulerProject\p067_triangle.txt'

m = 0
data = []
with open(path) as f:
    for i in f.readlines():
        i = i.replace("\n","")
        lineData = i.split(" ")
        tmp = [int(ld) for ld in lineData]
        data.append(tmp)

now_line = data[-1]
for da in range(len(data)-2,-1,-1):
    tmp = []
    for ind in range(len(data[da])):
        tmp.append(max(now_line[ind]+data[da][ind],data[da][ind]+now_line[ind+1]))
    now_line = tmp
print(now_line)